/*
* ECARX Technology Limited is the owner of the copyright and the trade secret of this software. 
* Without permission, no one has the right to obtain, disclose or use this software in any way.
*/
package com.example.soscall.utils;

import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;

import android.content.Context;
import android.content.Intent;

import com.example.soscall.MyApplication;


public class IntentUtil {
    private static String TAG = IntentUtil.class.getSimpleName();

    public static void startHome(){
        Intent homeIntent = new Intent(Intent.ACTION_MAIN);
        homeIntent.addCategory(Intent.CATEGORY_HOME);
        homeIntent.setFlags(FLAG_ACTIVITY_NEW_TASK);
        MyApplication.sApp.startActivity(homeIntent);
    }

    /**
     * 通知其它app ECALL弹框显示和关闭
     * @param show: true 界面显示; false 界面关闭
     */
    public static void notifyEcallScreenShow(boolean show) {
        try {
            Intent intent = new Intent("ecarx.intent.action.ECALL_SCREEN_SHOW");
            intent.putExtra("show", show );
            MyApplication.sApp.sendBroadcast(intent);
        } catch (Exception e){
            e.printStackTrace();
        }
    }


    /**
     * 获取当前activity是否存在
     * @param context
     * @param activityName
     * @return
     */
    public static boolean activityShow(Context context,String activityName){

        Intent intent = new Intent();
        intent.setClassName(context.getPackageName(),activityName);
        if (null != context.getPackageManager()) {
            if (intent.resolveActivity(context.getPackageManager()) == null) {
                return false;
            }
        }
        return  true;
    }


}
